//
//  BTEOrderTableViewCell.swift
//  BTE
//
//  Created by Mike Zhang on 2025/8/20.
//

import UIKit

class BTEOrderTableViewCell: UITableViewCell {
    
    private let box = UIView()
    
    let topBox = UIView()

    let timage = UIImageView()
    
    let ttittt = UILabel.init()
    
    let button = UIButton()
    
    
    let listbox = UIView()
    
    let proview = UIView()
    let p1 = UILabel()
    let p2 = UILabel()
  
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        button.isUserInteractionEnabled = false
        
        contentView.addSubview(box)
        box.roundCorners(.allCorners, radius: 10)
        box.backgroundColor = .white
        box.layer.borderColor = UIColor.colorWithHex("#6C2724")!.cgColor
        box.layer.borderWidth = 3
        box.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.bottom.equalToSuperview().inset(8)
        }
    
        box.addSubview(topBox)
        topBox.roundCorners([.topLeft,.topRight], radius: 10)
        topBox.backgroundColor = .colorWithHex("#FFF8D6")
        topBox.layer.borderColor = UIColor.colorWithHex("#6C2724")!.cgColor
        topBox.layer.borderWidth = 3
        topBox.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(8)
            make.top.equalToSuperview().inset(8)
            make.height.equalTo(70)
        }
        
        
        topBox.addSubview(timage)
        topBox.addSubview(ttittt)
        topBox.addSubview(button)
        
        timage.roundCorners(.allCorners, radius: 6)
        timage.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.centerY.equalToSuperview()
            make.width.equalTo(30)
            make.height.equalTo(30)
        }
        
        ttittt.font = .systemFont(ofSize: 18)
        ttittt.textColor = .black
        ttittt.snp.makeConstraints { make in
            make.centerY.equalTo(timage)
            make.left.equalTo(timage.snp.right).offset(8)
        }
        
        button.setTitleColor(UIColor.colorWithHex("#187CA5")!)
        button.setFont(.systemFont(ofSize: 16))
        button.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-16)
            make.centerY.equalTo(timage)
        }
        
        // 添加列表
        box.addSubview(listbox)
      
        
        box.addSubview(proview)
        proview.roundCorners(.allCorners, radius: 8)
        proview.backgroundColor = .white
        proview.layer.borderColor = UIColor.colorWithHex("#6C2724")!.cgColor
        proview.layer.borderWidth = 2
        proview.isHidden = true
     

        p2.text = BTELanguageManager.shared.localizedString(forKey: "view>")
        p1.textColor = .black
        p2.textColor = .colorWithHex("#187CA5")
        
        proview.addSubview(p1)
        proview.addSubview(p2)
        p1.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(12)
            make.top.bottom.equalToSuperview().inset(14)
        }
        
        p2.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-14)
            make.centerY.equalToSuperview()
        }
        
        proview.snp.makeConstraints{ make in
            make.left.right.equalToSuperview().inset(26)
            make.top.equalTo(listbox.snp.bottom).offset(10)
        }
        
        listbox.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(26)
            make.top.equalTo(topBox.snp.bottom).offset(10)
            make.bottom.equalToSuperview().offset(-12)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}



final class OrderListView: UIView {
    
    let lab = UILabel()
    
    let rihgtl = UILabel()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        lab.textColor = .colorWithHex("#999999")
        lab.font = .systemFont(ofSize: 14)
        
        rihgtl.textColor = .colorWithHex("#333333")
        rihgtl.font = .systemFont(ofSize: 15, weight: .bold)
        
        addSubview(lab)
        addSubview(rihgtl)
        
        lab.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview()
        }
        
        rihgtl.snp.makeConstraints { make in
            make.top.bottom.right.equalToSuperview()
        }
    }
    
    required  init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
